package com.lize.threaduse;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.Random;
import java.util.Scanner;

public class Homework01 {

    public static void main(String[] args) {
     A a=new A();
     a.start();
        B b = new B(a);
        b.start();

    }
}
class A extends Thread{

    private boolean loop=true;
    public void run(){

        while (loop){

            System.out.println(new Random().nextInt(100)+1);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }


    }

    public void setLoop(boolean loop) {
        this.loop = loop;
    }
}
class B extends Thread{
 private  A a;
 private Scanner sca=new Scanner(System.in);

    public  B(A a){
     this.a=a;
 }
public  void run(){

    while (true) {
        System.out.println("请输入你的指令");

        char key=sca.next().toUpperCase().charAt(0);

        if(key=='Q')
        {
            a.setLoop(false);
            System.out.println("b线程退出");
            break;
        }

    }
    System.out.println("axiancheng");

}

}